import java.util.Scanner;

public class Word {
    /**
     * 使用switch语句模拟登录
     * @param args
     */
    public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
        int count = 3;
        boolean tmp = false;
        while(count > 0) {
            System.out.print("请输入密码：");
            String str = scanner.nextLine();
            switch(str) {
                case "abcd":
                    System.out.println("密码输入正确，登录成功");
                    tmp = true;
                    break;
                default:
                    count--;
                    System.out.println("密码错误，还剩"+count+"次机会");
                    break;
            }
            if(tmp) {
                break;
            }
        }
    }
    public static void main8(String[] args) {
        //汉诺塔问题,hanoi

        hanoi(3,'A','B','C');

    }
    public static void move(char start,char end) {
        System.out.print(start+"->"+end+" ");
    }
    /**
     *
     * @param n
     * @param pos1  起始位置
     * @param pos2  中转位置
     * @param pos3  目的位置
     */
    public static void hanoi(int n,char pos1,char pos2,char pos3) {
        if(n==1) {
            move(pos1,pos3);
            return;
        }
        //多个盘子,先把上面的n-1移走
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);//再把最下面的大盘子挪到C

        hanoi(n-1,pos2,pos1,pos3);

    }
    public static void main7(String[] args) {
        //斐波拉契
        int N = 8;
        int sum = fib(N);
        System.out.println(sum);
    }
    public static int fib(int n) {
        if(n<=2) {
            return 1;
        }
        return fib(n-2)+fib(n-1);
    }
    public static void main6(String[] args) {
        //求数字的每一位之和
        int N = 12345;
        int sum = sumEvery(N);
        System.out.println(sum);
    }
    public static int sumEvery(int n) {
        if(n==1) {
            return n;
        }
        return n%10+sumEvery(n/10);
    }
    public static void main5(String[] args) {
        //顺序打印数组的每一位
        int num = 1234;
        print(num);
    }
    public static void print(int n) {
        if(n<10) {
            System.out.print(n);
            return;
        }
        print(n/10);
        System.out.print(n%10);

    }
    public static void main4(String[] args) {
        //递归求和
        int N = 3;
        int sum = sum(N);
        System.out.println(sum);
    }
    public static int sum(int n) {
        if(n==1) {
            return 1;
        }
        return n+sum(n-1);
    }
    public static void main3(String[] args) {
        //递归求N的阶乘
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int sum = sub(N);
        System.out.println(sum);
    }
    public static int sub(int n) {
        if(n==1) {
            return 1;
        }
        return n * sub(n-1);
    }
    //上一次作业
    public static void main2(String[] args) {
        int a = 10;
        int b = 15;
        int c = 30;
        int i = max2(a,b);
        System.out.println(i);
        int j = max3(a,b,c);
        System.out.println(j);
    }
    public static int max2(int x,int y) {
        return x>y?x:y;
    }
    public static int max3(int x,int y,int z) {
        int a1 = max2(x,y);
        int a2 = max2(a1,z);
        return a2;
    }
    public static void main1(String[] args) {

        int i = 1;
        float sum1 = 0f;
        float sum2 = 0f;
        for(i=1;i<=100;i+=2) {
            sum1+=1.0/i;
        }
        for(i=2;i<=100;i+=2) {
            sum2+=1.0/i;
        }
        System.out.println(sum1-sum2);
    }
}
